﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LaunchAllaround.DesignPattern.MVC
{
    [Serializable]
    public class ModelImpl<T> : Model<T> where T : Model<T>
    {

        [NonSerialized] private Container<View<T>> views;


        public ModelImpl()   
        {
            this.views = new Container<View<T>>();        
        }

        public void AddView(View<T> v)
        {
            this.views.Add(v);
        }

        public Container<View<T>> GetViews()
        {
            return this.views;
        }

        public void ClearViews()
        {
            this.views.Clear();
        }

        public void RefreshViews(RefreshEvent<T> ev)
        {
            foreach (View<T> v in this.views)
            {
                v.Refresh(ev);
            }
        }
    }
}
